from app import db, db2


class SchichtKalender(db.Model):
    __tablename__ = 'SCHICHTKALENDER'
    LINIE_KZ = db.Column(db.String(16))
    LB_KZ = db.Column(db.String(16))
    FB_OPERATION = db.Column(db.String(8), primary_key=True)
    DATUM = db.Column(db.DateTime, primary_key=True)
    SCHICHT = db.Column(db.String(8), primary_key=True)
    SCHICHT_VON = db.Column(db.DateTime)
    SCHICHT_BIS = db.Column(db.DateTime)
    SOLL_STUECK = db.Column(db.Integer)
    PROG_STUECK = db.Column(db.Integer)

    def __repr__(self):
        return '<SCHICHTKALENDER %r>' % self.SCHICHT_VON


class StandARDSchichtModelle(db.Model):
    __tablename__ = 'STANDARDSCHICHTMODELLE'
    SS_ID = db.Column(db.Integer, primary_key=True)
    LINIE_KZ = db.Column(db.String(16))
    GUELTIG_VON = db.Column(db.DateTime)
    MODELLNAME = db.Column(db.String(8))

    def __repr__(self):
        return '<STANDARDSCHICHTMODELLE %r>' % self.SS_ID


class StandARDSchichten(db.Model):
    __tablename__ = 'STANDARDSCHICHTEN'
    MD_ID = db.Column(db.Integer, primary_key=True)
    TAG = db.Column(db.String(1), primary_key=True)
    SCHICHT = db.Column(db.String(1), primary_key=True)

    def __repr__(self):
        return '<STANDARDSCHICHTEN %r>' % self.MD_ID


class StandardModelle(db.Model):
    __tablename__ = 'STANDARDMODELLE'
    MD_ID = db.Column(db.Integer, primary_key=True)
    SS_ID = db.Column(db.Integer)
    MODELL_NR = db.Column(db.String(1))
    PROD_VON = db.Column(db.String(8))
    PROD_BIS = db.Column(db.String(8))
    SOLL_STUECK = db.Column(db.Integer)
    PROG_STUECK = db.Column(db.Integer)
    AKTIV = db.Column(db.String(1))

    def __repr__(self):
        return '<STANDARDMODELLE %r>' % self.MD_ID


class StueckZAHLProSchicht(db.Model):
    __tablename__ = 'STUECKZAHLPROSCHICHT'
    LINIE_KZ = db.Column(db.String(16), primary_key=True)
    STUECK_KZ = db.Column(db.String(8), primary_key=True)
    DATUM = db.Column(db.DateTime, primary_key=True)
    FB_OPERATION = db.Column(db.String(8), primary_key=True)
    FMA_ZELLE = db.Column(db.String(8), primary_key=True)
    FMA_BAZ = db.Column(db.String(8), primary_key=True)
    SACHNR_ZB = db.Column(db.String(16), primary_key=True)
    STUECK = db.Column(db.Integer)
    IO_NIO_KZ = db.Column(db.String(8), primary_key=True)

    def __repr__(self):
        return '<STUECKZAHLPROSCHICHT %r>' % self.DATUM


class SchichtKalenderGrossAnzeige(db.Model):
    __bind_key__ = 'PSS_Archive_Production_INFO_G6'
    __tablename__ = 'SCHICHTKALENDER_GROSSANZEIGE'
    NG6SK_DATUM = db.Column(db.String(8), primary_key=True)
    SCHICHT_KZ = db.Column(db.String(1))
    SCHICHT_VON = db.Column(db.DateTime)
    SCHICHT_BIS = db.Column(db.DateTime)
    SOLL_STUECK = db.Column(db.Integer)
    PROG_STUECK = db.Column(db.Integer)

    def __repr__(self):
        return '<SCHICHTKALENDER_GROSSANZEIGE %r>' % self.NG6SK_DATUM


class NG6OOSEREIGNISSE(db.Model):
    __bind_key__ = 'PSS_Archive_Production_INFO_G6'
    __tablename__ = 'NG6_OOSEREIGNISSE'
    NOE_ID = db.Column(db.Integer, primary_key=True)
    NR_J = db.Column(db.Integer, primary_key=True)
    OPERATION = db.Column(db.String(10))
    ZELLE = db.Column(db.String(3))
    BAZ = db.Column(db.String(3))
    BEARB_DATUM = db.Column(db.DateTime)
    SACHNR_ZB = db2.Column(db2.String(16))

    def __repr__(self):
        return '<NG6_OOSEREIGNISSE %r>' % self.NOE_ID


class NG6EINZELEREIGNISSE(db.Model):
    __bind_key__ = 'PSS_Archive_Production_INFO_G6'
    __tablename__ = 'NG6_EINZELEREIGNISSE'
    NEE_ID = db.Column(db.Integer, primary_key=True)
    NR_J = db.Column(db.Integer, primary_key=True)
    OPERATION = db.Column(db.String(10))
    ZELLE = db.Column(db.String(3))
    BAZ = db.Column(db.String(3))
    BEARB_DATUM = db.Column(db.DateTime)

    def __repr__(self):
        return '<NG6_EINZELEREIGNISSE %r>' % self.NEE_ID


class ArchivWSANBAU(db.Model):
    __bind_key__ = 'PSS_Archive_Production_G6'
    __tablename__ = 'ARCHIV_WSANBAU'
    SERIEN_NR = db.Column(db.Integer, primary_key=True)
    OPERATION = db.Column(db.String(10))
    BEARB_DATUM = db.Column(db.DateTime)

    def __repr__(self):
        return '<ARCHIV_WSANBAU %r>' % self.SERIEN_NR


class ArchivWorkLog(db.Model):
    __bind_key__ = 'PSS_Archive_Production_G6'
    __tablename__ = 'ARCHIV_WORKLOG'
    SERIEN_NR = db.Column(db.Integer, primary_key=True)
    BEARB_DATUM = db.Column(db.DateTime)
    ZEITSTEMPEL = db.Column(db.DateTime)
    OPERATION = db.Column(db.String(10), primary_key=True)
    ZELLE = db.Column(db.String(8), primary_key=True)
    BAZ = db.Column(db.String(8), primary_key=True)
    FERTEINR_OP = db.Column(db.String(10), primary_key=True)
    FERTEINR_ZN = db.Column(db.String(8), primary_key=True)
    FERTEINR_BAZ = db.Column(db.String(8), primary_key=True)
    VORRICHTUNG = db.Column(db.Integer)
    UEBERLAUF = db.Column(db.Integer)

    def __repr__(self):
        return '<ARCHIV_WORKLOG %r>' % self.SERIEN_NR


class ArchivAKTBDEMA(db.Model):
    __bind_key__ = 'PSS_Archive_Production_G6'
    __tablename__ = 'ARCHIV_AKTBDE_MA'
    QUELLE_OP = db.Column(db.String(16), primary_key=True)
    QUELLE_ZN = db.Column(db.String(8), primary_key=True)
    QUELLE_BAZ = db.Column(db.String(8), primary_key=True)
    ZEITSTEMPEL = db.Column(db.DateTime)
    AKTGRUND = db.Column(db.Integer)
    AKT_AKTGRUND = db.Column(db.Integer)

    def __repr__(self):
        return '<ARCHIV_AKTBDE_MA %r>' % self.QUELLE_OP


class Z6SchichtKalenderGrossAnzeige(db2.Model):
    __bind_key__ = 'PSS_Archive_Production_INFO_Z6'
    __tablename__ = 'SCHICHTKALENDER_GROSSANZEIGE'
    NG6SK_DATUM = db2.Column(db2.String(8), primary_key=True)
    SCHICHT_KZ = db2.Column(db2.String(1))
    SCHICHT_VON = db2.Column(db2.DateTime)
    SCHICHT_BIS = db2.Column(db2.DateTime)
    SOLL_STUECK = db2.Column(db2.Integer)
    PROG_STUECK = db2.Column(db2.Integer)

    def __repr__(self):
        return '<SCHICHTKALENDER_GROSSANZEIGE %r>' % self.NG6SK_DATUM


class Z6NG6OOSEREIGNISSE(db2.Model):
    __bind_key__ = 'PSS_Archive_Production_INFO_Z6'
    __tablename__ = 'NG6_OOSEREIGNISSE'
    NOE_ID = db2.Column(db2.Integer, primary_key=True)
    NR_J = db2.Column(db2.Integer, primary_key=True)
    OPERATION = db2.Column(db2.String(10))
    ZELLE = db2.Column(db2.String(3))
    BAZ = db2.Column(db2.String(3))
    BEARB_DATUM = db2.Column(db2.DateTime)
    SACHNR_ZB = db2.Column(db2.String(16))

    def __repr__(self):
        return '<NG6_OOSEREIGNISSE %r>' % self.NOE_ID


class Z6NG6EINZELEREIGNISSE(db2.Model):
    __bind_key__ = 'PSS_Archive_Production_INFO_Z6'
    __tablename__ = 'NG6_EINZELEREIGNISSE'
    NEE_ID = db2.Column(db2.Integer, primary_key=True)
    NR_J = db2.Column(db2.Integer, primary_key=True)
    OPERATION = db2.Column(db2.String(10))
    ZELLE = db2.Column(db2.String(3))
    BAZ = db2.Column(db2.String(3))
    BEARB_DATUM = db2.Column(db2.DateTime)

    def __repr__(self):
        return '<NG6_EINZELEREIGNISSE %r>' % self.NEE_ID


class Z6ArchivWorkLog(db2.Model):
    __bind_key__ = 'PSS_Archive_Production_Z6'
    __tablename__ = 'ARCHIV_WORKLOG'
    SERIEN_NR = db2.Column(db2.Integer, primary_key=True)
    BEARB_DATUM = db2.Column(db2.DateTime)
    ZEITSTEMPEL = db2.Column(db2.DateTime)
    OPERATION = db2.Column(db2.String(10), primary_key=True)
    ZELLE = db2.Column(db2.String(8), primary_key=True)
    BAZ = db2.Column(db2.String(8), primary_key=True)
    FERTEINR_OP = db.Column(db.String(10), primary_key=True)
    FERTEINR_ZN = db.Column(db.String(8), primary_key=True)
    FERTEINR_BAZ = db.Column(db.String(8), primary_key=True)
    VORRICHTUNG = db2.Column(db2.Integer)
    UEBERLAUF = db2.Column(db2.Integer)

    def __repr__(self):
        return '<ARCHIV_WORKLOG %r>' % self.SERIEN_NR


class Z6ArchivAKTBDEMA(db2.Model):
    __bind_key__ = 'PSS_Archive_Production_Z6'
    __tablename__ = 'ARCHIV_AKTBDE_MA'
    QUELLE_OP = db2.Column(db2.String(16), primary_key=True)
    QUELLE_ZN = db2.Column(db2.String(8), primary_key=True)
    QUELLE_BAZ = db2.Column(db2.String(8), primary_key=True)
    ZEITSTEMPEL = db2.Column(db2.DateTime)
    AKTGRUND = db2.Column(db2.Integer)
    AKT_AKTGRUND = db2.Column(db2.Integer)

    def __repr__(self):
        return '<ARCHIV_AKTBDE_MA %r>' % self.QUELLE_OP
